package com.xueyi.aixihu.controller;

import com.xueyi.aixihu.controller.base.BaseController;
import com.xueyi.aixihu.entity.vo.*;
import com.xueyi.aixihu.exception.SzException;
import com.xueyi.aixihu.reqeust.AgreePassNewsAuditReq;
import com.xueyi.aixihu.reqeust.FindWaitAuditNewsListReq;
import com.xueyi.aixihu.response.base.BaseResponse;
import com.xueyi.aixihu.service.NewAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author hxs
 * @createDate 2023/6/29 18:11
 * @description 审核文章相关接口
 */
@RestController
public class AuditNewsController extends BaseController {

    @Autowired
    private NewAuditService newAuditService;

    /**
     * 查询待审核文章
     *
     * @param findWaitAuditNewsListReq 参数
     * @return 审核记录列表
     */
    @RequestMapping("/audit/news/findWaitAuditNewsList")
    public BaseResponse<DataList<WaitAuditNewsVo>> findWaitAuditNewsList(@Validated FindWaitAuditNewsListReq findWaitAuditNewsListReq) throws SzException {
        DataList<WaitAuditNewsVo> flag = newAuditService.findWaitAuditNewsList(findWaitAuditNewsListReq);
        return BaseResponse.success(flag);
    }

    /**
     * 通过审核文章
     *
     * @param agreePassNewsAuditReq 参数
     * @return 响应成功
     */
    @RequestMapping("/audit/news/agreePassNewsAudit")
    public BaseResponse<Boolean> agreePassNewsAudit(@Validated AgreePassNewsAuditReq agreePassNewsAuditReq) throws SzException {
        newAuditService.agreePassNewsAudit(agreePassNewsAuditReq);
        return BaseResponse.success(Boolean.TRUE);

    }

    /**
     * 查询待审核文章数据
     *
     * @return 待审核文章数据
     */
    @RequestMapping("/audit/news/findWaitAuditNewsSize")
    public BaseResponse<FindWaitAuditNewsSizeVo> findWaitAuditNewsSize(Integer auditType) throws SzException {
        FindWaitAuditNewsSizeVo flag = newAuditService.findWaitAuditNewsSize(auditType);
        return BaseResponse.success(flag);
    }

    /**
     * 查询文章审核日志
     *
     * @param id 文章id
     * @return 日志列表
     */
    @RequestMapping("/audit/news/findNewsAuditLog")
    public BaseResponse<List<AxhAuditFinanceLogVo>> findNewsAuditLog(Integer id) throws SzException {
        List<AxhAuditFinanceLogVo> list = newAuditService.findNewsAuditLog(id, Boolean.TRUE);
        return BaseResponse.success(list);
    }

    /**
     * 通过id查询待审核文章对象
     *
     * @param id 文章id
     * @return 待审核文章对象
     */
    @RequestMapping("/audit/news/findNewsVoById")
    public BaseResponse<WaitAuditNewsVo> findNewsVoById(Integer id) throws SzException {
        WaitAuditNewsVo flag = newAuditService.findNewsVoById(id);
        return BaseResponse.success(flag);
    }

    /**
     * 查询分类列表
     *
     * @return 分类列表
     */
    @RequestMapping("/audit/news/findClassifyList")
    public BaseResponse<List<BaseSelectVo>> findClassifyList() {
        List<BaseSelectVo> list = newAuditService.findClassifyList();
        return BaseResponse.success(list);
    }
}
